package day16;

import java.util.TreeSet;

public class TreeSet01 {
    public static void main(String[] args) {
        Student s1 = new Student ("xiaoming",18,60,60,60);
        Student s2 = new Student ("xiaowang",19,70,50,60);
        Student s3 = new Student ("xiaogang",17,80,40,70);
        Student s4 = new Student ("xiaoli",21,70,70,50);
        Student s5 = new Student ("xiaomei",20,100,100,100);
        TreeSet <Student> ts = new TreeSet<>((o1, o2) ->{
            int sum1=o1.getChineseScore()+o1.getMathScore()+o1.getEnglishScore();
            int sum2=o2.getChineseScore()+o2.getMathScore()+o2.getEnglishScore();
            if(sum1!=sum2) return sum2-sum1;
            else if(o1.getChineseScore()!=o2.getChineseScore()) return o2.getChineseScore()-o1.getChineseScore();
            else if(o1.getMathScore()!=o2.getMathScore()) return o2.getMathScore()-o1.getMathScore();
            else if(o1.getEnglishScore()!= o2.getEnglishScore()) return o2.getEnglishScore()-o1.getEnglishScore();
            else if(o1.getAge()!=o2.getAge()) return o1.getAge()-o2.getAge();
            else if(!o1.getName().equals(o2.getName())) return o1.getName().compareTo(o2.getName());
            else return 0;
        });
        ts.add(s1);
        ts.add(s2);
        ts.add(s3);
        ts.add(s4);
        ts.add(s5);
        System.out.println(ts);
    }

}
